<?php

	/**
	 * @see Bike_Js_VarPart_Object
	 */
	require_once 'Bike/Js/VarPart/Object.php';
	
	
	class Bike_Js_Ext_Msg_Show extends Bike_Js_VarPart_Object
	{
        protected $_part = 'show';

		protected function initDefaultSettings()
		{
			parent::initDefaultSettings();
		
			$js = $this->js();
			$this->setSettings(array(
				'title' => $this->translate('Attention'),
				'buttons' => $this->getJsButtons(),
				'icon' => $this->getJsIcon(),
			));
		}
		
		/**
		 * Get JS buttons
		 *
		 * @return Bike_Js_Interface_Js object
		 */
		protected function getJsButtons()
		{
			if(!$this->getParamCache(__METHOD__))
			{
				$js = $this->js();
		
				$this->setParamCache(__METHOD__, $js->Ext->Msg->OK);
			}
			return $this->getParamCache(__METHOD__);
		}
		
		/**
		 * Get JS icon
		 *
		 * @return Bike_Js_Interface_Js object
		 */
		protected function getJsIcon()
		{
			if(!$this->getParamCache(__METHOD__))
			{
				$js = $this->js();
		
				$this->setParamCache(__METHOD__, $js->Ext->Msg->INFO);
			}
			return $this->getParamCache(__METHOD__);
		}

		protected function _makeOptions(array $Args=null)
		{
			$options = array();
			$argsCount = sizeof($Args);
			if($argsCount)
			{
				if($argsCount == 1 && is_array($Args[0]) && isset($Args[0]['msg']))
				{
					$options = $Args[0];
				}
				elseif($argsCount == 1)
				{
					$options = array(
						'msg' => $Args[0],
					);
				}
				elseif($argsCount >= 2)
				{
					$options = array(
						'msg' => $Args[0],
						'title' => $Args[1],
					);
				}
			}
			return $options;
		}
	}
